package com.gdziarmaga.webshop.review.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.gdziarmaga.webshop.book.model.Book;

@Entity
@Table(name = "Review")
public class Review implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final String NICK = "nick";
	public static final String REVIEW_DATE = "review_date";
	public static final String BOOK = "book";

	private long review_id;
	private String nick;
	private String text;
	private Date review_date;
	private int note;
	
	@Column(name = "note", nullable = false, length = 10)
	public int getNote() {
		return note;
	}

	public void setNote(int note) {
		this.note = note;
	}

	private Book book;

	// @OneToMany(fetch=FetchType.EAGER)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "book_id_FK", nullable = false, updatable = false)
	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "review_seq")
	@SequenceGenerator(name = "review_seq", sequenceName = "REVIEW_SEQ")
	@Column(name = "review_id", precision = 20, scale = 0, unique = true)
	public long getReview_id() {
		return review_id;
	}

	public void setReview_id(long review_id) {
		this.review_id = review_id;
	}

	@Column(name = "nick", nullable = false, length = 100)
	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	@Column(name = "text", nullable = false, length = 100)
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@Column(name = "review_date", nullable = false, length = 100)
	public Date getReview_date() {
		return review_date;
	}

	public void setReview_date(Date review_date) {
		this.review_date = review_date;
	}

}
